<div class="actions">
    <?php echo $this->Html->link('파일 업로드', array('controller' => 'Upload', 'action' => 'index', $this->passedArgs[0]))?>
    <?php echo $this->Html->link('동접', array('action' => 'server_count', $this->passedArgs[0]))?>
</div>
<table>
    <?php echo $this->Form->create('notice', array('onsubmit' => 'return confirm("전송 할까요???");')); ?>
    <tr>
        <td style="width: 80px;border-bottom:0px;font-weight: bold;">공지 사항</td>
        <td style="width: 500px;font-size: 12px;border-bottom:0px;">
            <?php echo $this->Form->input('msg', array(
                'label' => false,
                'value' => '',
            ))?>
        </td>
        <td style="width: 40px;border-bottom:0px;">
            <?php echo $this->Form->end(__('전송')); ?>
        </td >
        <td style="border-bottom:0px;">

        </td>
        <td style="border-bottom:0px;">

        </td>
        <td style="border-bottom:0px;">

        </td>
    </tr>
</table>


<table>
    <?php /*echo $this->Form->create('notice', array('onsubmit' => 'return confirm("전송 할까요???");')); */?><!--
    <tr>
        <td style="width: 80px;border-bottom:0px;font-weight: bold;">공지 사항</td>
        <td style="width: 500px;font-size: 12px;border-bottom:0px;">
            <?php /*echo $this->Form->input('msg', array(
                'label' => false,
                'value' => '',
            ))*/?>
        </td>
        <td style="width: 40px;border-bottom:0px;">
            <?php /*echo $this->Form->end(__('전송')); */?>
        </td >
        <td style="border-bottom:0px;">

        </td>
        <td style="border-bottom:0px;">

        </td>
        <td style="border-bottom:0px;">

        </td>
    </tr>-->
</table>

<?php if(empty($account_info)) {
    return;
}?>

<?php /*echo '평균 스테이지 : ' . $stage_average*/?><!--
<?php /*if(!empty($char_average)) {*/?>
    <?php /*echo ', 평균 골드 : ' . $char_average['gold']*/?>
    <?php /*echo ', 평균 레벨 : ' . $char_average['level']*/?>
--><?php /*}*/?>

<table>
    <tr>
        <th style="width: 40px;text-align: center;">번호</th>
        <th style="width: 230px;text-align: center;">USN</th>
        <th style="width: 220px;text-align: center;">닉네임</th>
        <th style="width: 130px;text-align: center;">IP</th>
        <th style="width: 170px;text-align: center;">가입날짜</th>
        <th style="width: 30px;text-align: center;">접속</th>
        <th colspan="2" style="text-align: center;">스테이지</th>
        <th colspan="2" style="text-align: center;">레벨</th>
        <th style="text-align: center;">재료</th>
        <th style="text-align: center;">스킬</th>
        <th style="text-align: center;">동료</th>
        <th style="text-align: center;">비고</th>
    </tr>
    <?php $count = count($account_info) ?>
    <?php foreach($account_info as $num => $data): ?>
        <tr>
            <td><?php echo $count-- ?></td>

            <td><?php echo $data['Account']['_id']?></td>

            <td class="actions">
                <?php if(empty($data['Account']['nick_name'])) {?>
                    캐릭 없음
                <?php } else {?>
                    <?php foreach($data['Account']['nick_name'] as $nick => $char_id) {?>
                        <?php echo $nick . ', ' . $char_id?>
                        <?php echo $this->Html->link('캐릭터 삭제', array(
                            'action' => 'char_del',
                            'char_id' => $char_id,
                            'usn' => $data['Account']['_id'],
                            $this->passedArgs[0]
                        ),array(),"정말 삭제 할까요?")?>
                        <?php /*echo $this->Html->link('계정 삭제', array(
                            'action' => 'char_del',
                            'char_id' => $char_id,
                            'usn' => $data['Account']['_id'],
                            $this->passedArgs[0]
                        ),array(),"정말 삭제 할까요?")*/?>
                    <?php }?>
                <?php }?>
            </td>
            <td>
                <?php /*if($data['Account']['connect_ip'] == '121.67.181.202') {*/?><!--
                    <?php /*echo 'A2X GAMES'*/?>
                <?php /*} else {*/?>
                    <a href="http://www.ipipipip.net/data/index.php?ip=<?/*=$data['Account']['connect_ip']*/?>&ln=ko">
                        <?php /*echo $data['Account']['connect_ip']*/?>
                    </a>
                --><?php /*}*/?>
            </td>
            <td>
                <?php echo mongoDateToTime($data['Account']['created'])?>
            </td>
            <td style="text-align: center;"><?php /*echo $data['Account']['connect_count'] */?></td>
            <?php echo $this->Form->create('stage', array('onsubmit' => 'return confirm("변경 할까요???");')); ?>

            <?php if(empty($data['Account']['nick_name'])) {?>
                <td style="text-align: center">없음</td>
                <td style="text-align: center">없음</td>
            <?php } else {?>
                <td style="width: 60px;font-size: 13px" class="actions">

                    <?php echo $this->Form->hidden('char_id', array(
                        'label' => false,
                        'value' => empty($data['Account']['char_id']) ? '' : $data['Account']['char_id'],
                        'escape' => false
                    ));?>

                    <?php echo $this->Form->input('stage_clear', array(
                        'label' => false,
                        'type' => 'select',
                        'options' => $stage_option,
                        'value' => empty($data['Account']['stage_clear']) ? '' : $data['Account']['stage_clear'],
                    ))?>
                </td>
                <td style="width: 40px;font-size: 12px">
                    <?php echo $this->Form->end(__('저장')); ?>
                </td>
            <?php }?>

            <?php if(empty($data['Account']['nick_name'])) {?>
                <td>없음</td>
                <td>없음</td>
                <td>없음</td>
                <td>없음</td>
                <td>없음</td>
            <?php } else {?>
                <td style="width: 30px;font-size: 13px;text-align: center;" class="actions">
                    <b><?php echo($data['Account']['level'])?></b>
                </td>

                <td style="width: 40px;font-size: 12px">
                    <div><?php echo $this->Form->create('level'); ?></div>
                    <?php echo $this->Form->hidden('usn', array(
                        'label' => false,
                        'value' => $data['Account']['_id'],
                        'escape' => false
                    ));?>
                    <?php echo $this->Form->hidden('char_id', array(
                        'label' => false,
                        'value' => $data['Account']['char_id'],
                        'escape' => false
                    ));?>
                    <?php echo $this->Form->end(__('렙업')); ?>
                </td>

                <td style="width: 40px;font-size: 12px">
                    <div><?php echo $this->Form->create('material', array('onsubmit' => 'return confirm("모든 재료 50개씩 저장합니다. 콜?");')); ?></div>
                    <?php echo $this->Form->hidden('usn', array(
                        'label' => false,
                        'value' => $data['Account']['_id'],
                        'escape' => false
                    ));?>
                    <?php echo $this->Form->hidden('char_id', array(
                        'label' => false,
                        'value' => $data['Account']['char_id'],
                        'escape' => false
                    ));?>
                    <?php echo $this->Form->end(__('재료')); ?>
                </td>

                <td style="width: 40px;font-size: 12px">
                    <div><?php echo $this->Form->create('skill', array('onsubmit' => 'return confirm("모든 패시브 스킬을 저장합니다. 콜?");')); ?></div>
                    <?php echo $this->Form->hidden('usn', array(
                        'label' => false,
                        'value' => $data['Account']['_id'],
                        'escape' => false
                    ));?>
                    <?php echo $this->Form->hidden('char_id', array(
                        'label' => false,
                        'value' => $data['Account']['char_id'],
                        'escape' => false
                    ));?>
                    <?php echo $this->Form->end(__('스킬')); ?>
                </td>

                <td style="width: 40px;font-size: 12px">
                    <div><?php echo $this->Form->create('monster', array('onsubmit' => 'return confirm("모든 동료를 고용합니다. 콜?");')); ?></div>
                    <?php echo $this->Form->hidden('usn', array(
                        'label' => false,
                        'value' => $data['Account']['_id'],
                        'escape' => false
                    ));?>
                    <?php echo $this->Form->hidden('char_id', array(
                        'label' => false,
                        'value' => $data['Account']['char_id'],
                        'escape' => false
                    ));?>
                    <?php echo $this->Form->end(__('고용')); ?>
                </td>

            <?php }?>
            <td></td>
        </tr>
    <?php endforeach ?>
</table>

<div class="actions">
    <?php echo $this->Html->link('디비 초기화', array('action' => 'delete_all', $this->passedArgs[0]),array(),"정말 초기화 할까요?")?>
</div>

<?php echo $this->Session->flash('good') ?>
<?php echo $this->Session->flash('bad') ?>